import { ModuleConfig } from '../../../bootstrap/interface';
import { routes } from './routes';
import en_api from './i18n/en_api.json';
import ru_api from './i18n/ru_api.json';
import { Bootstrap } from '../../../bootstrap';
import { GetUserProfileUseCase } from '../usecase/getUserProfileUseCase.ts';
import { AuthService } from '../../auth/service/auth.service.ts';

export default {
  ROUTES: () => routes,

  I18N: (i18n) => {
    i18n.addResourceBundle('en', 'user', en_api);
    i18n.addResourceBundle('ru', 'user', ru_api);
  },
  afterBootstrapInit: async (bootstrap: Bootstrap) => {
    const authService = bootstrap.di.get<AuthService>(AuthService);
    const getUserProfileUseCase = bootstrap.di.get<GetUserProfileUseCase>(
      GetUserProfileUseCase,
    );

    authService.setAfterAuthCallback(async () => {
      await getUserProfileUseCase.execute();
    });
  },
} as ModuleConfig;
